// @import
import GameScene from "./GameScene";
import { __UI__listenOperationAreaEvent } from "./GameScene.UI.__listenOperationAreaEvent";

/**
 * 初始化 UI, 主要是负责注册事件
 * 
 * @param SELF this 指针
 */
export function __UI_onLoad(SELF: GameScene): void {
    __UI__listenOperationAreaEvent(SELF);

    // 获取帮助节点
    let oButton_HelpNode: cc.Node = cc.find("/Canvas/UI/Layout_BottomBar/Button_Help");
    oButton_HelpNode.on(cc.Node.EventType.TOUCH_END, () => {
        // 查找帮助对话框节点
        let oTalkBox_HelpNode: cc.Node = cc.find("Holder_TalkBox_Help", oButton_HelpNode);
        oTalkBox_HelpNode.resumeAllActions();

        let funTw = cc.tween;

        if (oTalkBox_HelpNode.active) {
            // 隐藏对话框
            funTw(oTalkBox_HelpNode)
                .to(0.2, { angle: 30, opacity: 0, })
                .call(() => { oTalkBox_HelpNode.active = false; })
                .start();
        }
        else {
            // 显示对话框
            oTalkBox_HelpNode.active = true;
            oTalkBox_HelpNode.angle = 30;

            funTw(oTalkBox_HelpNode)
                .to(0.5, { angle: 0, opacity: 255, }, { easing: "elasticOut", })
                .start();
        }
    });
}
